﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using SharedGenomics.TextMining;

namespace SharedGenomics.Workbench.Tests.TextMining
{
    [TestClass]
    public class TileSectionTests
    {
        [TestMethod]
        public void ConstructorTestNonTermValid()
        {
            TileSection ts = new TileSection("text");

            Assert.AreEqual("text", ts.Text);
            Assert.AreEqual(1, ts.Quartile);
            Assert.IsFalse(ts.IsTerm);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorTestNonTermInvalidNull()
        {
            TileSection ts = new TileSection(null);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void ConstructorTestNonTermInvalidEmpty()
        {
            TileSection ts = new TileSection(String.Empty);
        }

        [TestMethod]
        public void ConstructorTestTermValid()
        {
            TileSection ts = new TileSection(new ScoredTerm("text", 0.1), 2);
            Assert.AreEqual("text", ts.Text);
            Assert.IsTrue(ts.IsTerm);
            Assert.AreEqual(0.1, ts.CValue);
            Assert.AreEqual(2, ts.Quartile);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructorTestTermInvalidTermNull()
        {
            TileSection ts = new TileSection(null, 1);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ConstructorTestTermInvalidQuartileTooSmall()
        {
            TileSection ts = new TileSection(new ScoredTerm("text", 0.1), 0);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void ConstructorTestTermInvalidQuartileTooLarge()
        {
            TileSection ts = new TileSection(new ScoredTerm("text", 0.2), 5);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void CValueTestNonTerm()
        {
            TileSection ts = new TileSection("text");
            double cValue = ts.CValue;
        }
    }
}
